package com.easytake.emotioncat.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.easytake.emotioncat.dto.PageResult;
import com.easytake.emotioncat.entity.EmFeedbackEntity;
import com.easytake.emotioncat.mapper.EmFeedbackMapper;
import com.easytake.emotioncat.service.IEmFeedbackService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 反馈记录表 服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2022-11-02
 */
@Service
public class EmFeedbackServiceImpl extends ServiceImpl<EmFeedbackMapper, EmFeedbackEntity> implements IEmFeedbackService {

    @Override
    public PageResult<EmFeedbackEntity> getListByPage(Integer pageNo, Integer pageSize) {
        EmFeedbackMapper mapper = this.getBaseMapper();
        Page<EmFeedbackEntity> page = Page.of(pageNo, pageSize);
        QueryWrapper<EmFeedbackEntity> queryWrapper = new QueryWrapper<>();
        OrderItem orderItem = OrderItem.desc("create_time");
        List<OrderItem> orderItemList = new ArrayList<>();
        orderItemList.add(orderItem);
        page.setOrders(orderItemList);
        IPage<EmFeedbackEntity> entityIPage = mapper.selectPage(page, queryWrapper);
        PageResult pageResult = new PageResult(entityIPage);
        return pageResult;
    }
}
